package com.igoal.service.dwr;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.igoal.dto.CommentDTO;
import com.igoal.dto.DWRPageDTO;
import com.igoal.dto.FriendDTO;
import com.igoal.dto.GoalDTO;
import com.igoal.dto.UserGoalDTO;
import com.igoal.entity.ComponentEnum;
import com.igoal.service.SaveResult;

public interface GoalManagerDWR {

	/**
	 * UserSession create new goal
	 * 
	 * @param goal
	 *            the model of goal {@link GoalDTO}
	 * @return {@link SaveResult}
	 */
	@Transactional(readOnly = false)
	UserGoalDTO createNewGoal(GoalDTO goal);

	boolean isThisGoalInUserGoalList(GoalDTO goal);

	/**
	 * Add a comment to {@link ComponentEnum} by user session
	 * 
	 * @param dto
	 *            the model of comment {@link CommentEntryDTO}
	 * @return {@link SaveResult}
	 */
	@Transactional(readOnly = false)
	CommentDTO addComment(CommentDTO dto);

	/**
	 * Delete the comment by user session. <br/>
	 * 
	 * @param dto
	 *            the model of comment {@link CommentEntryDTO}
	 * @return {@link SaveResult}
	 */
	int deleteComment(Long commentId);

	int removeGoal(Long goalId);

	int deleteGoalEntry(Long entryId);

	@Transactional(readOnly = false)
	int doneGoal(Long goalId);

	@Transactional(readOnly = false)
	int doGoal(Long goalId);

	@Transactional(readOnly = true)
	List<String> findGoalByTitle(String title);

	@Transactional(readOnly = false)
	int updateUserGoalPercent(Long goalId, Integer percent);

	/**
	 * Get 3 random users who like this entry
	 * 
	 * @param entryId
	 * @param isEntryDone
	 * @return
	 */
	@Transactional(readOnly = true)
	List<FriendDTO> getRandomEntryLikeList(Long userId, Long entryId, boolean isEntryDone);

	/**
	 * Get a page of users who like this entry
	 * 
	 * @param entryId
	 * @param isEntryDone
	 * @param pageId
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	@Transactional(readOnly = true)
	DWRPageDTO getEntryEntryLikeList(Long entryId, boolean isEntryDone, int pageId, int totalPage);
	
	int updateTaskSuccess(Long taskId);
	
	int updateTaskNotSuccess(Long taskId);
}
